import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { NodeService } from './node.service';
import { CreateNodeDto } from './dto/create-node.dto';
import { UpdateNodeDto } from './dto/update-node.dto';

@Controller('node')
export class NodeController {
  constructor(private readonly nodeService: NodeService) {}

   //分页查询
   @Post('/pageList')
   async getPage(@Body() body) {
     return this.nodeService.getPage(body);
   }

  //  获取已部署节点
  @Post('/getDeployedNodes')
  async getDeployedNodes(@Body() body) {
    return this.nodeService.getDeployedNodes(body);
  }

  // 获取可部署节点
  @Post('/getUndeployedNodes')
  async getUndeployedNodes(@Body() body) {
    return this.nodeService.getUndeployedNodes(body);
  }

  // 节点条件查询
  @Post('/queryList')
  async queryList(@Body() body) {
    return this.nodeService.queryList(body);
  }

  //根据节点ID获取部署文件信息
  @Post('/getNodeDepFile')
  async getNodeDepFile(@Body() body) {
    return this.nodeService.getNodeDepFile(body);
  }

  //批量删除节点
  @Post('/batchDeleteNode')
  async batchDeleteNode(@Body() body) {
    return this.nodeService.batchDeleteNode(body);
  }

  // 获取节点cpu和内存数据
  @Post('/getNodeCpuAndMem')
  async getNodeCpuAndMem(@Body() body) {
    return this.nodeService.getNodeCpuAndMem(body);
  }


  // 故障注入
  @Post('/faultInjection')
  async faultInjection(@Body() body) {
    return this.nodeService.faultInjection(body);
  }

  //下发停止注入
  @Post('/stopFaultInjection')
  async stopFaultInjection(@Body() body) {
    return this.nodeService.stopFaultInjection(body);
  }

  //获取排除宿主机的所有节点
  @Post('/queryAll')
  async getNodesExcludeHost(@Body() body) {
    return this.nodeService.getNodesExcludeHost(body);
  }


  // 保存和修改节点
  @Post('/saveOrUpdate')
  async saveOrUpdate(@Body() body) {
    return this.nodeService.saveOrUpdate(body);
  }


  //查询在线节点,按部署物数量从大到小排序
  @Post('/queryOnline')
  async queryOnlineNodes(@Body() body) {
    return this.nodeService.queryOnline(body);
  }


}
